package cn.edu.scau.cmi.linjinyong.fxml.mybatis;

import cn.edu.scau.cmi.linjinyong.mybatis.domain.Student;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleStringProperty;

public class StudentData {
    private SimpleLongProperty id;
    private SimpleStringProperty name;
    private SimpleStringProperty major;
    private SimpleStringProperty teacherName;
    private SimpleBooleanProperty haveChoosed;
    private SimpleBooleanProperty haveBeenChoosed;

    public StudentData(Student student){
        this.id = new SimpleLongProperty(student.getId());
        this.name = new SimpleStringProperty(student.getName());
        this.major = new SimpleStringProperty(student.getMajor());
        this.teacherName = new SimpleStringProperty(
                student.getConfirm() == 1? student.getTeacher().getName() : "无" );
        this.haveChoosed = new SimpleBooleanProperty((student.getTeacher() == null));
        this.haveBeenChoosed = new SimpleBooleanProperty((student.getConfirm() == 1));
    }

    //accessor
    public long getId() {
        return id.get();
    }

    public SimpleLongProperty idProperty() {
        return id;
    }

    public void setId(long id) {
        this.id.set(id);
    }

    public String getName() {
        return name.get();
    }

    public SimpleStringProperty nameProperty() {
        return name;
    }

    public void setName(String name) {
        this.name.set(name);
    }

    public String getTeacherName() {
        return teacherName.get();
    }

    public SimpleStringProperty teacherNameProperty() {
        return teacherName;
    }

    public void setTeacherName(String teacherName) {
        this.teacherName.set(teacherName);
    }

    public String getMajor() {
        return major.get();
    }

    public SimpleStringProperty majorProperty() {
        return major;
    }

    public void setMajor(String major) {
        this.major.set(major);
    }

    public boolean isHaveChoosed() {
        return haveChoosed.get();
    }

    public SimpleBooleanProperty haveChoosedProperty() {
        return haveChoosed;
    }

    public void setHaveChoosed(boolean haveChoosed) {
        this.haveChoosed.set(haveChoosed);
    }

    public boolean isHaveBeenChoosed() {
        return haveBeenChoosed.get();
    }

    public SimpleBooleanProperty haveBeenChoosedProperty() {
        return haveBeenChoosed;
    }

    public void setHaveBeenChoosed(boolean haveBeenChoosed) {
        this.haveBeenChoosed.set(haveBeenChoosed);
    }
}
